package com.example.blank.Dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;

import com.example.blank.utils.DBConnectionUtils;

public class CourseDao {
	
	public static HashMap getCourseDetailById(String id)
	{
		Connection connection = null;
		Statement statement = null;
		ResultSet resultSet = null;
		int i = 0;
		try{
			connection = DBConnectionUtils.getConnection(connection);
			statement = connection.createStatement();
			resultSet = statement.executeQuery("select course_id, course_sum, course_position,"
					+ " course_t_number, course_c_number, course_start, course_end, course_point"
					+ " , course_now_sum from course_detail where course_id='"+id+"';");
			resultSet.last();
			if(resultSet.getRow() <= 0)
			{
				return null;
			}
			resultSet.first();
			
			HashMap map = new HashMap();
			map.put("course_id", (String)resultSet.getString(1));
			map.put("course_sum", resultSet.getInt(2));
			map.put("course_position", (String)resultSet.getString(3));
			map.put("course_t_number", resultSet.getInt(4));
			map.put("course_c_number", resultSet.getInt(5));
			map.put("course_start", resultSet.getInt(6));
			map.put("course_end", resultSet.getInt(7));
			map.put("course_point", resultSet.getDouble(8));
			map.put("course_now_sum", resultSet.getInt(9));
			return map;
			
		}catch(Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}

}
